package br.com.mucceli.politicapopular.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author mucceli
 */
@Entity
@Table(name = "PESQUISA")
@NamedQueries({
    @NamedQuery(name = "Pesquisa.findAll", query = "SELECT p FROM Pesquisa p"),
    @NamedQuery(name = "Pesquisa.findByIdPesquisa", query = "SELECT p FROM Pesquisa p WHERE p.idPesquisa = :idPesquisa")})
public class Pesquisa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_PESQUISA")
    private Integer idPesquisa;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 65535)
    @Column(name = "NOME_PESQUISA")
    private String nomePesquisa;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkPesquisa")
    private Collection<Estatisticas> estatisticasCollection;

    public Pesquisa() {
    }

    public Pesquisa(Integer idPesquisa) {
        this.idPesquisa = idPesquisa;
    }

    public Pesquisa(Integer idPesquisa, String nomePesquisa) {
        this.idPesquisa = idPesquisa;
        this.nomePesquisa = nomePesquisa;
    }

    public Integer getIdPesquisa() {
        return idPesquisa;
    }

    public void setIdPesquisa(Integer idPesquisa) {
        this.idPesquisa = idPesquisa;
    }

    public String getNomePesquisa() {
        return nomePesquisa;
    }

    public void setNomePesquisa(String nomePesquisa) {
        this.nomePesquisa = nomePesquisa;
    }

    public Collection<Estatisticas> getEstatisticasCollection() {
        return estatisticasCollection;
    }

    public void setEstatisticasCollection(Collection<Estatisticas> estatisticasCollection) {
        this.estatisticasCollection = estatisticasCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPesquisa != null ? idPesquisa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pesquisa)) {
            return false;
        }
        Pesquisa other = (Pesquisa) object;
        if ((this.idPesquisa == null && other.idPesquisa != null) || (this.idPesquisa != null && !this.idPesquisa.equals(other.idPesquisa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.mycompany.mavenproject1.Pesquisa[ idPesquisa=" + idPesquisa + " ]";
    }
    
}
